# Maintainer: Dan Printzell <wild@archlinux.org>
# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>
# Contributor: dsboger <https://github.com/dsboger>
# Contributor: Carl George < arch at cgtx dot us >

pkgname=tilix
pkgver=1.9.5
pkgrel=6
pkgdesc="A tiling terminal emulator for Linux using GTK+ 3"
arch=('loong64' 'x86_64')
url="https://github.com/gnunn1/tilix"
license=('MPL')
depends=('libx11' 'gtkd' 'vte3' 'dconf' 'gsettings-desktop-schemas')
makedepends=('ldc' 'po4a' 'meson' 'appstream')
optdepends=('python-nautilus: for "Open Tilix Here" support in nautilus'
            'libsecret: for the password manager')
source=(
  "$url/archive/$pkgver/$pkgname-$pkgver.tar.gz"
  "Add-compatibility-with-Nautilus-43.patch::$url/pull/2115.patch"
  "undeaD-1.1.8.tar.gz::https://github.com/dlang/undeaD/archive/refs/tags/v1.1.8.tar.gz"
  "undeaD-xml.patch"
)
sha256sums=('e25335a3f7ab06779b957d08ffaf7698c966c3b5179d002f82ce41c692fc0b89'
            '5ad54f9627d0035f6025b684ffab831341d8bdcf597b3f4a8146b09014c418b5'
            '36a59b4740b147f4345caa26908f40a97fc7cc67dac6983c226369c59f909e92'
            '989295aadf8d3d0fa90d1b7cd01558293956bb4a753dbbdc05d92d486596bf25')

prepare() {
  patch --directory="$pkgname-$pkgver" --forward --strip=1 --input "$srcdir"/Add-compatibility-with-Nautilus-43.patch
  patch --directory="$pkgname-$pkgver" --forward --strip=1 --input "$srcdir"/undeaD-xml.patch

  mkdir -p build
  cd "$srcdir"/$pkgname-$pkgver
  ln -s "$srcdir"/undeaD-1.1.8
}

build() {
  cd build

  # Build with LDC
  export DC=ldc
  export LDFLAGS="$(echo -ne $LDFLAGS | sed -e 's/-flto=auto//')"
  export DFLAGS="--flto=full"

  arch-meson ../$pkgname-$pkgver

  ninja
}

package() {
  cd build

  DESTDIR="$pkgdir" ninja install
}
